var util = require("../../../utils/util.js"),
{api} = require("../../../utils/api.js"),
    app = getApp();
Page({

    /**
     * 页面的初始数据
     */
    data: {
        userInfo: null,
        integral: null,
        bgImgUrl:app.globalData.baseUrl+'/wxImage/signActionBg.png',
        shareLogo:null
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
        wx.hideShareMenu();
        this.getUsers();
        this.integralIndex();
    },
    bindpatient(){
        wx.navigateTo({
          url: '/pages/mine/thePatient/thePatient',
        })
    },
    async integralIndex(){
        const {data} = await api.IntegralIndex();
        this.setData({shareLogo:data.share_logo})
    },
    async getUsers() {
        const data = await app.getUsers();
        if(data){
            if(data.userInfo.is_submit){
                wx.showShareMenu();
            }
            this.setData(data)
        }
    },
    gotoPage(e) {
        let {
            url,
            type,
            login
        } = e.currentTarget.dataset;
        if (login == 1 && util.getUserInfo(this.data.userInfo, true) == false)return false;
        if(!url)return false;
        type == 'tab' ? wx.switchTab({
            url
        }) : wx.navigateTo({
            url
        });
    },
    gotoJf(){
        wx.navigateTo({
          url: '/pages/mine/points/points',
        })
    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage(e) {
        return {
            title: '摩尔小程序',
            path: '/pages/index/index?share_id=' + this.data.userInfo.id,
            imageUrl:this.data.shareLogo
        }
    }
})